_init(layoutManager, monitor, x, y) {
super._init();
- // We use this flag to mark the case where the user has entered the
- // hot corner and has not left both the hot corner and a surrounding
- // guard area (the "environs"). This avoids triggering the hot corner
- // multiple times due to an accidental jitter.
- this._entered = false;
-
this._monitor = monitor;
this._x = x;
this._y = y;
- this._setupFallbackCornerIfNeeded(layoutManager);
-
this._pressureBarrier = new PressureBarrier(
HOT_CORNER_PRESSURE_THRESHOLD,
HOT_CORNER_PRESSURE_TIMEOUT,
}
}
- _setupFallbackCornerIfNeeded(layoutManager) {
- const {capabilities} = global.backend;
- if ((capabilities & Meta.BackendCapabilities.BARRIERS) === 0) {
- this.set({
- name: 'hot-corner-environs',
- x: this._x,
- y: this._y,
- width: 3,
- height: 3,
- reactive: true,
- });
-
- this._corner = new Clutter.Actor({
- name: 'hot-corner',
- width: 1,
- height: 1,
- opacity: 0,
- reactive: true,
- });
- this._corner._delegate = this;
-
- this.add_child(this._corner);
- layoutManager.addChrome(this);
-
- if (Clutter.get_default_text_direction() === Clutter.TextDirection.RTL) {
- this._corner.set_position(this.width - this._corner.width, 0);
- this.set_pivot_point(1.0, 0.0);
- this.translation_x = -this.width;
- } else {
- this._corner.set_position(0, 0);
- }
-
- this._corner.connect('enter-event',
- this._onCornerEntered.bind(this));
- this._corner.connect('leave-event',
- this._onCornerLeft.bind(this));
- }
- }
-
_onDestroy() {
this.setBarrierSize(0);
this._pressureBarrier.destroy();
return DND.DragMotionResult.CONTINUE;
}
-
- _onCornerEntered() {
- if (!this._entered) {
- this._entered = true;
- this._toggleOverview();
- }
- return Clutter.EVENT_PROPAGATE;
- }
-
- _onCornerLeft(actor, event) {
- if (event.get_related() !== this)
- this._entered = false;
- // Consume event, otherwise this will confuse onEnvironsLeft
- return Clutter.EVENT_STOP;
- }
-
- vfunc_leave_event(event) {
- if (event.get_related() !== this._corner)
- this._entered = false;
- return Clutter.EVENT_PROPAGATE;
- }
});
export class PressureBarrier extends Signals.EventEmitter {